<template>
  <div class="app-container">
    <el-form v-show="showSearch" ref="queryForm" :inline="true" :model="queryParams" label-width="68px" size="small">
      <el-form-item label="" prop="id">
        <el-input
          v-model="queryParams.id"
          clearable
          placeholder="请输入卡券ID"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="couponsName">
        <el-input
          v-model="queryParams.couponsName"
          clearable
          placeholder="请输入名称"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="卡券昵称别名" prop="couponsNickName">
              <el-input
                v-model="queryParams.couponsNickName"
                placeholder="请输入卡券昵称别名"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="卡券使用说明" prop="description">
              <el-input
                v-model="queryParams.description"
                placeholder="请输入卡券使用说明"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="折扣比例 %" prop="discount">
              <el-input
                v-model="queryParams.discount"
                placeholder="请输入折扣比例 %"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="有效时间 (秒)" prop="effectiveSecond">
              <el-input
                v-model="queryParams.effectiveSecond"
                placeholder="请输入有效时间 (秒)"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="是否启用" prop="enable">
              <el-input
                v-model="queryParams.enable"
                placeholder="请输入是否启用"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="仅仅持有一次" prop="holdOnceOnly">
              <el-input
                v-model="queryParams.holdOnceOnly"
                placeholder="请输入仅仅持有一次"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="最大抵扣额" prop="maxDeduction">
              <el-input
                v-model="queryParams.maxDeduction"
                placeholder="请输入最大抵扣额"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="卡券触发阈值" prop="minThreshold">
              <el-input
                v-model="queryParams.minThreshold"
                placeholder="请输入卡券触发阈值"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>-->
      <el-form-item label="" prop="platformAgentId">
        <el-select v-model="queryParams.platformAgentId" clearable placeholder="请选择代理商">
          <el-option
            v-for="dict in agentList"
            :key="dict.id"
            :label="dict.agentName"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="couponsSubType">
        <el-cascader
          v-model="queryParams.couponsSubType"
          :options="couponsTypeList"
        ></el-cascader>
      </el-form-item>
      <el-form-item label="" prop="enable">
        <el-select v-model="queryParams.enable" clearable placeholder="请选择是否启用">
          <el-option
            key="1"
            label="关闭"
            value="0"
          />
          <el-option
            key="2"
            label="开启"
            value="1"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="payType">
        <el-select v-model="queryParams.payType" clearable placeholder="请选择支付方式">
          <el-option
            v-for="dict in couponsPayTypeList"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="writeOffType">
        <el-select v-model="queryParams.writeOffType" clearable placeholder="请选择核销类型">
          <el-option
            v-for="dict in writeOffTypeList"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <!--      <el-form-item label="代理商名称" prop="platformAgentName">
              <el-input
                v-model="queryParams.platformAgentName"
                placeholder="请输入代理商名称"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="售价 (分)" prop="price">
              <el-input
                v-model="queryParams.price"
                placeholder="请输入售价 (分)"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="叠加使用" prop="usedAlone">
              <el-input
                v-model="queryParams.usedAlone"
                placeholder="请输入叠加使用"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="虚拟部分" prop="virPart">
              <el-input
                v-model="queryParams.virPart"
                placeholder="请输入虚拟部分"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>-->
      <el-form-item>
        <el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['activitys:coupons:add']"
          icon="el-icon-plus"
          plain
          size="mini"
          type="primary"
          @click="handleAdd"
        >新增卡券
        </el-button>
      </el-col>
      <!--      <el-col :span="1.5">
              <el-button
                type="success"
                plain
                icon="el-icon-edit"
                size="mini"
                :disabled="single"
                @click="handleUpdate"
                v-hasPermi="['activitys:coupons:edit']"
              >修改</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                size="mini"
                :disabled="multiple"
                @click="handleDelete"
                v-hasPermi="['activitys:coupons:remove']"
              >删除</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="warning"
                plain
                icon="el-icon-download"
                size="mini"
                @click="handleExport"
                v-hasPermi="['activitys:coupons:export']"
              >导出</el-button>
            </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="couponsList" @selection-change="handleSelectionChange">
<!--      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form class="demo-table-expand" inline label-position="left">
            <el-form-item label="最大抵扣额">
              <span>{{ props.row.maxDeduction }}</span>
            </el-form-item>
            <el-form-item label="折扣比例">
              <span>{{ props.row.discount }}</span>
            </el-form-item>
            <el-form-item label="触发阈值">
              <span>{{ props.row.minThreshold }}</span>
            </el-form-item>
            <el-form-item label="卡面金额">
              <span>{{ props.row.cashPart }}</span>
            </el-form-item>
            <el-form-item label="卡面赠送金额">
              <span>{{ props.row.virPart }}</span>
            </el-form-item>
            <el-form-item label="支付方式">
              <span>{{ props.row.payType }}</span>
            </el-form-item>
            <el-form-item label="售价">
              <span>{{ props.row.price }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>-->
      <el-table-column align="center" label="卡券ID" prop="id"/>
      <el-table-column align="center" label="名称" prop="couponsName"/>
      <el-table-column align="center" label="别名" prop="couponsNickName"/>
      <el-table-column align="center" label="归属代理商" prop="platformAgentName"/>
      <el-table-column align="center" label="类型" prop="couponsType"/>
      <el-table-column align="center" label="子类型" prop="couponsSubType"/>
      <el-table-column align="center" label="是否启用" prop="enable"/>
      <el-table-column align="center" label="核销类型" prop="writeOffType"/>
      <el-table-column align="center" label="持有限制" prop="holdOnceOnly"/>
      <el-table-column align="center" label="叠加使用" prop="usedAlone"/>
      <el-table-column align="center" label="有效时间" prop="effectiveSecond"/>

      <!--      <el-table-column label="现金部分" align="center" prop="cashPart" />
            <el-table-column label="卡券使用说明" align="center" prop="description" />
            <el-table-column label="折扣比例 %" align="center" prop="discount" />
            <el-table-column label="最大抵扣额" align="center" prop="maxDeduction" />
            <el-table-column label="卡券触发阈值" align="center" prop="minThreshold" />
            <el-table-column label="支付方式" align="center" prop="payType" />
            <el-table-column label="售价 (分)" align="center" prop="price" />
            <el-table-column label="虚拟部分" align="center" prop="virPart" />-->

      <el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="148">
        <template slot-scope="scope">
          <el-button
            v-hasPermi="['activitys:coupons:edit']"
            icon="el-icon-info"
            size="mini"
            type="text"
            @click="handleDetails(scope.row)"
          >详情
          </el-button>
          <el-button
            v-hasPermi="['activitys:coupons:edit']"
            icon="el-icon-edit"
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
          >修改
          </el-button>
          <el-button
            v-hasPermi="['activitys:coupons:remove']"
            icon="el-icon-delete"
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :limit.sync="queryParams.pageSize"
      :page.sync="queryParams.pageNum"
      :total="total"
      @pagination="getList"
    />

    <!-- 添加或修改卡券对话框 -->
    <el-dialog :title="title" :visible.sync="open" append-to-body width="80%">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px"
               style="width: 100%;display: flex;justify-content: space-between;">
        <div style="flex:1;max-height: 112px;display: flex;justify-content: space-between;flex-wrap: wrap;">
          <el-form-item label="名称" prop="couponsName">
            <el-input v-model="form.couponsName" placeholder="请输入名称" :disabled="detailsType"/>
          </el-form-item>
          <el-form-item label="卡券昵称别名" prop="couponsNickName">
            <el-input v-model="form.couponsNickName" placeholder="请输入卡券昵称别名" :disabled="detailsType"/>
          </el-form-item>
          <el-form-item label="类型" prop="couponsSubType">
            <el-cascader
              :disabled="detailsType"
              v-model="form.couponsSubType"
              :options="couponsTypeList"
              style="width: 200px"
              @change="handleCouponsType"
            ></el-cascader>
          </el-form-item>
          <el-form-item label="核销类型" prop="writeOffType">
            <el-select v-model="form.writeOffType" clearable placeholder="请选择核销类型" style="width: 200px" :disabled="detailsType">
              <el-option
                v-for="dict in writeOffTypeList"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>

          <!--          <el-form-item label="卡券使用说明" prop="description">
                      <el-input v-model="form.description" placeholder="请输入卡券使用说明" />
                    </el-form-item>-->
          <el-form-item v-if="couponsType==='zkq'||couponsType==='dkq'" label="最大抵扣额" prop="maxDeduction">
            <el-input v-model="form.maxDeduction" placeholder="请输入最大抵扣额" :disabled="detailsType"/>
          </el-form-item>
          <el-form-item v-if="couponsType==='zkq'" label="折扣比例 %" prop="discount">
            <el-input-number v-model="form.discount" controls-position="right" :min="0" :max="100" :disabled="detailsType"></el-input-number>
          </el-form-item>
          <el-form-item v-if="couponsType==='zkq'||couponsType==='dkq'" label="卡券触发阈值" prop="minThreshold">
            <el-input v-model="form.minThreshold" placeholder="请输入卡券触发阈值" :disabled="detailsType"/>
          </el-form-item>
          <el-form-item v-if="couponsType==='zfk'" label="现金" prop="cashPart">
            <el-input v-model="form.cashPart" placeholder="请输入现金部分" :disabled="detailsType"/>
          </el-form-item>
          <el-form-item v-if="couponsType==='zfk'" label="赠送金额" prop="virPart">
            <el-input v-model="form.virPart" placeholder="请输入虚拟部分" :disabled="detailsType"/>
          </el-form-item>
          <!--          <el-form-item label="有效时间 (秒)" prop="effectiveSecond">
                      <el-input v-model="form.effectiveSecond" placeholder="请输入有效时间 (秒)" />
                    </el-form-item>
                    <el-form-item label="是否启用" prop="enable">
                      <el-input v-model="form.enable" placeholder="请输入是否启用" />
                    </el-form-item>
                    <el-form-item label="仅仅持有一次" prop="holdOnceOnly">
                      <el-input v-model="form.holdOnceOnly" placeholder="请输入仅仅持有一次" />
                    </el-form-item>-->
        </div>
        <div style="flex:1;height: auto;display: flex;justify-content: space-between;flex-wrap: wrap;">
          <el-form-item label="售价" prop="price">
            <el-input v-model="form.price" placeholder="请输入售价 (分)" :disabled="detailsType"/>
          </el-form-item>
          <el-form-item label="支付方式" prop="payType">
            <el-select v-model="form.payType" clearable placeholder="请选择支付方式" :disabled="detailsType">
              <el-option
                v-for="dict in couponsPayTypeList"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="叠加使用" prop="usedAlone">
            <el-switch
              :disabled="detailsType"
              v-model="form.usedAlone"
              active-color="#13ce66"
              active-value="1"
              inactive-color="#ff4949"
              inactive-value="0">
            </el-switch>
<!--            <el-input-number v-model="form.usedAlone" controls-position="right" :min="1" ></el-input-number>-->
          </el-form-item>
          <el-form-item label="持有限制" prop="holdOnceOnly">
            <el-input-number v-model="form.holdOnceOnly" controls-position="right" :min="0" :disabled="detailsType"></el-input-number>
          </el-form-item>
          <el-form-item label="归属代理商" prop="platformAgentId">
            <el-select v-model="form.platformAgentId" clearable placeholder="请选择代理商" @change="handleChange" :disabled="detailsType">
              <el-option
                v-for="dict in agentList"
                :key="dict.id"
                :label="dict.agentName"
                :value="dict.id"
              />
            </el-select>
            <!--            <el-input v-model="form.platformAgentId" placeholder="请输入代理商ID" />-->
          </el-form-item>
          <el-form-item label="有效时间" prop="effectiveSecond">
            <el-input-number v-model="form.effectiveSecond" controls-position="right" :min="0" :disabled="detailsType"></el-input-number>
          </el-form-item>
          <!--          <el-form-item label="代理商名称" prop="platformAgentName">-->
          <!--            <el-input v-model="form.platformAgentName" placeholder="请输入代理商名称" />-->
          <!--          </el-form-item>-->

          <div style="width: 100%">
            <!--            <el-form-item label="使用说明" prop="descriptionList">
                          <el-input v-model="form.descriptionList" placeholder="请输入有效时间"/>
                        </el-form-item>-->
            <el-form-item
              v-for="(domain, index) in form.descriptionList"
              :key="domain.key"
              :label="'使用说明' + index"
              :prop="'descriptionList.' + index + '.value'"
              :rules="{
                  required: true, message: `使用说明${index}不能为空`, trigger: 'blur'
                }"
            >
              <div style="display: flex;align-items: flex-start">
                <el-input v-model="domain.value" style="width: 300px;margin-right: 5px" :disabled="detailsType"></el-input>
                <el-button style="display: inline-block" v-if="index>0" @click.prevent="removeDomain(domain)">删除</el-button>
              </div>
            </el-form-item>
            <el-form-item>
              <el-button @click="addDomain">新增使用说明</el-button>
            </el-form-item>
          </div>

        </div>


      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listCoupons,
  getCoupons,
  delCoupons,
  addCoupons,
  updateCoupons,
  findAllCouponsType, findAllWriteOffType, findAllCouponsPayType
} from "@/api/business/coupons";
import {getAgentAll} from "@/api/platform/agent";
import fa from "element-ui/src/locale/lang/fa";

export default {
  name: "Coupons",
  data() {
    const  validateAmount = /^\d+(\.\d{1,2})?$/
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 卡券表格数据
      couponsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: null,
        cashPart: null,
        couponsName: null,
        couponsNickName: null,
        couponsSubType: null,
        couponsType: null,
        description: null,
        discount: null,
        effectiveSecond: null,
        enable: null,
        holdOnceOnly: null,
        maxDeduction: null,
        minThreshold: null,
        payType: null,
        platformAgentId: null,
        platformAgentName: null,
        price: null,
        usedAlone: null,
        virPart: null,
        writeOffType: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        couponsName: {required: true, message: '请填写卡券名称',trigger: 'blur' },
        couponsNickName: {required: true, message: '请填写卡券别名',trigger: 'blur' },
        couponsSubType: {required: true, message: '请选择类型',trigger: 'change' },
        writeOffType: {required: true, message: '请选择核销类型',trigger: 'change' },
        maxDeduction:[
          {required: true, message: '请填写最大抵扣额',trigger: 'blur' },
          { pattern: validateAmount, trigger: 'blur' }
        ],
        minThreshold:[
          {required: true, message: '请填写最小触发阈值',trigger: 'blur' },
          { pattern: validateAmount, trigger: 'blur' }
        ],
        cashPart:[
          {required: true, message: '请填写现金',trigger: 'blur' },
          { pattern: validateAmount, trigger: 'blur' }
        ],
        virPart:[
          {required: true, message: '请填写赠送金',trigger: 'blur' },
          { pattern: validateAmount, trigger: 'blur' }
        ],
        price:[
          {required: true, message: '请填写售价',trigger: 'blur' },
          { pattern: validateAmount, trigger: 'blur' }
        ],
        payType: {required: true, message: '请选择支付方式',trigger: 'change' },
        platformAgentId: {required: true, message: '请选择代理商',trigger: 'change' },
      },
      agentList: [],
      couponsTypeList: [],
      writeOffTypeList: [],
      couponsPayTypeList: [],
      couponsType: null,
      detailsType:false
    };
  },
  created() {
    this.getList();
    this.getAgentAll()
    this.getFindAllCouponsType()
    this.getFindAllWriteOffType()
    this.getFindAllCouponsPayType()
  },
  methods: {
    handleChange(value, index){
      this.agentList.forEach(i=>{
        if (i.id===value) this.form.platformAgentName = i.agentName
      })
    },
    removeDomain(item) {
      const index = this.form.descriptionList.indexOf(item)
      if (index !== -1) {
        this.form.descriptionList.splice(index, 1)
      }
    },
    addDomain() {
      this.form.descriptionList.push({
        value: '',
        key: Date.now()
      });
    },
    handleCouponsType(val) {
      switch (val[1]) {
        case 'CO_1':
          console.log(1)
          this.couponsType = 'dkq'
          break;
        case 'CO_2':
          console.log(2)
          this.couponsType = 'zkq'
          break;
        case 'CA_1':
          this.couponsType = 'zfk'
          break;
        case 'IN_1':
          this.couponsType = 'jf'
          break;
        default:
          this.couponsType = null
      }
    },
    // 格式化级联选择器数据
    getCascadeData(data) {
      return Object.keys(data).reduce((accumulator, key) => {
        accumulator.push({
          value: key,
          label: key,
          children: data[key].map(item => ({
            value: item,
            label: item
          }))
        });

        return accumulator;
      }, []);
    },
    async getFindAllCouponsPayType() {
      let res = await findAllCouponsPayType()
      this.couponsPayTypeList = Object.entries(res.data).map(([key, value]) => {
        return {
          value: key,
          label: value
        };
      });

    },
    async getFindAllWriteOffType() {
      let res = await findAllWriteOffType()
      this.writeOffTypeList = Object.entries(res.data).map(([key, value]) => {
        return {
          value: key,
          label: value
        };
      });
    },
    async getFindAllCouponsType() {
      let res = await findAllCouponsType()
      this.couponsTypeList = res.data
    },
    async getAgentAll() {
      let res = await getAgentAll()
      this.agentList = res.rows
    },
    /** 查询卡券列表 */
    getList() {
      this.loading = true;
      listCoupons(this.queryParams).then(response => {
        this.couponsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        cashPart: null,
        couponsName: null,
        couponsNickName: null,
        couponsSubType: null,
        couponsType: null,
        description: null,
        discount: null,
        effectiveSecond: null,
        enable: null,
        holdOnceOnly: null,
        maxDeduction: null,
        minThreshold: null,
        payType: null,
        platformAgentId: null,
        platformAgentName: null,
        price: null,
        usedAlone: null,
        virPart: null,
        writeOffType: null,
        descriptionList: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if (this.queryParams.couponsSubType) this.queryParams.couponsSubType = this.queryParams.couponsSubType[1]
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      //新增初始化使用说明三条
      this.form.descriptionList = [[{
        value: '',
        key:0
      }], [{
        value: '',key:1
      }], [{
        value: '',key:2
      }]]
      this.detailsType = false
      this.open = true;
      this.title = "添加卡券";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getCoupons(id).then(response => {
        this.form = response.data;
        this.handleCouponsType([this.form.couponsType,this.form.couponsSubType])
        const list = []
        JSON.parse(this.form.description).forEach((item,index)=>{
          list.push({value:item,key:index})
        })
        this.form.descriptionList = list
        this.detailsType = false
        this.open = true;
        this.title = "修改卡券";
      });
    },
    /** 详情按钮操作 */
    handleDetails(row) {
      this.reset();
      const id = row.id || this.ids
      getCoupons(id).then(response => {
        this.form = response.data;
        this.handleCouponsType([this.form.couponsType,this.form.couponsSubType])
        const list = []
        JSON.parse(this.form.description).forEach((item,index)=>{
          list.push({value:item,key:index})
        })
        this.form.descriptionList = list
        this.detailsType = true
        this.open = true;
        this.title = "修改卡券";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.descriptionList = this.form.descriptionList.map(({ value }) => value)
          if (Array.isArray(this.form.couponsSubType) ) {
            this.form.couponsType = this.form.couponsSubType[0]
            this.form.couponsSubType = this.form.couponsSubType[1]
          }
          if (this.form.id != null) {
            updateCoupons(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCoupons(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除卡券编号为"' + ids + '"的数据项？').then(function () {
        return delCoupons(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('activitys/coupons/export', {
        ...this.queryParams
      }, `coupons_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style lang="scss" scoped>
.demo-table-expand {
  font-size: 0;
}

.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}

.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>
